1. Field of the Invention
The present invention relates to an image processing apparatus and method and a program, and, more particularly, to an image processing apparatus and method and a program, which are suitably used when image gray scale correction is performed.
2. Description of the Related Art
In the related art, as one image processing technology, without changing a detail component representative of texture, a gray scale correction process of compressing a luminance difference of another component is known (for example, see Japanese Unexamined Patent Application Publication No. 2009-177558).
Here, the outline of a gray scale correction process of Japanese Unexamined Patent Application Publication No. 2009-177558 will be described with reference to FIG. 1.
A luminance region information calculation unit 11 obtains a base value which is a luminance value of a base of a dark luminance side and a light luminance side of a histogram of a luminance value L(nl)(p) of an input image and stores such a base value in a luminance region information memory 12 as luminance region information. A block histogram calculation unit 13 divides the input image into a plurality of blocks in a spatial direction and a luminance direction, and calculates and stores a block histogram representing the number (frequency count) of pixels belonging to each block for each frame in a block histogram memory 14. A block integration value calculation unit 15 calculates and stores the integration value (total sum) of luminance values of pixels belonging to each block of the above-described input image for each frame in a block integration value memory 16.
A weighted sum-of-products unit 17 calculates a general luminance value Ll(nl)(p) representing approximate lightness of a subject to which each pixel of the input image belongs, based on the luminance value L(nl)(p) of the input image, the block histogram, and the block integration value. A tone curve calculation unit 18 calculates a tone curve for each pixel based on the luminance region information and the general luminance value Ll(nl)(p) and stores the tone curve in a tone curve memory 19. A mapping unit 20 compresses (corrects) the gray scale of the general luminance value Ll(nl)(p) based on the tone curve and supplies an obtained general luminance value Lcl(nl)(p) to a contrast correction unit 22. The mapping unit 21 compresses (corrects) the gray scale of the luminance value L(nl)(p) of the input image based on the tone curve and supplies an obtained luminance value Lc(nl)(p) to the contrast correction unit 22. The contrast correction unit 22 corrects the contrast of the luminance image including the luminance value Lc(nl)(p) based on the general luminance value Lcl(nl)(p), the luminance value Lc(nl)(p) and the tone curve and outputs a luminance value Lu(nl)(p) obtained as the result.